HIVE-29778: Log the effective user when creating a Hive session handle - #6657
Open
owenmonn wants to merge 1 commit into
Open
HIVE-29778: Log the effective user when creating a Hive session handle#6657owenmonn wants to merge 1 commit into
owenmonn wants to merge 1 commit into
Conversation
req.getUsername() is only populated when auth=noSasl, so the log read "user [null]" under Kerberos, LDAP/SASL PLAIN and HTTP transport. Use the resolved userName parameter that is passed to openSession instead.
ayushtkn
reviewed
Jul 29, 2026
| final String ipAddress = getIpAddress(); | ||
|
|
||
| LOG.info("Creating Hive session handle for user [{}] from IP {}", req.getUsername(), ipAddress); | ||
| LOG.info("Creating Hive session handle for user [{}] from IP {}", userName, ipAddress); |
Member
There was a problem hiding this comment.
shouldn't we do if req.getUsername() is null then log userName
Contributor
Author
There was a problem hiding this comment.
That fallback already exists in getUserName(), in the opposite direction:
if (userName == null) {
userName = req.getUsername();
}So adding a null check would only change behaviour when both are set, and there the raw value wins and we lose the shortname handling and the getProxyUser() result.
Whereas getUserName() is documented as "Returns the effective username", and that value is what the session is opened with.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What changes were proposed in this pull request?
ThriftCLIService#getSessionHandlenow logs the resolveduserNameparameter instead ofreq.getUsername().Why are the changes needed?
req.getUsername()is the rawTOpenSessionReqfield, which the Hive JDBC driver only populates whenauth=noSasl. Under Kerberos, LDAP/SASL PLAIN and HTTP transport the identity arrives via the SASL authorization ID or a thread-local, so the line logsCreating Hive session handle for user [null] from IP <ip>.The
userNameparameter is the resolved effective user that is actually passed toCLIService#openSession/#openSessionWithImpersonation.Does this PR introduce any user-facing change?
No functional change. The log line now shows the effective user instead of
null.How was this patch tested?
No new tests; log message change only.